home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-23 | 7.1 KB | 240 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: EditViews.h
- // Release Version: $ ODF 1 $
- //
- // Author: Mary Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef EDITVIEWS_H
- #define EDITVIEWS_H
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWEDVIEW_H
- #include "FWEdView.h"
- #endif
-
- #ifndef FWSCPTBL_H
- #include "FWScptbl.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
-
- #ifndef __TEXTSERVICES__
- #include <TextServices.h>
- #endif
-
- #ifndef __TSMTE__
- #include <TSMTe.h>
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class CIntlTestPart;
- class FW_CViewContext;
- class FW_CMouseEvent;
- class FW_CClipboardCommand;
- class CTypingCommand;
- class CTSMTypingCommand;
-
- //========================================================================================
- // Constants and Globals
- //========================================================================================
-
- extern FW_CFont gFontOsaka;
-
- const FW_Message kEditViewMsg = 45; // ASCII 'E'
-
- //----------------------------------------------------------------------------------------
- // Enumeration for ASCII Character Constants - copied from MacApp
- //----------------------------------------------------------------------------------------
-
- enum EAsciiControlCode {
- chBackspace = 8, // ASCII code for Backspace character
- chClear = 27, // ASCII code for Clear key (aka ESC)
- chDown = 31, // ASCII code for down arrow
- chEnd = 4, // ASCII code for the End key
- chEnter = 3, // ASCII code for Enter character
- chEscape = 27, // ASCII code for Escape (aka Clear) key
- chFunction = 16, // ASCII code for any function key
- chFwdDelete = 127, // ASCII code for forward delete
- chHelp = 5, // ASCII code for Help key
- chHome = 1, // ASCII code for the Home key
- chLeft = 28, // ASCII code for left arrow
- chPageDown = 12, // ASCII code for Page Down key
- chPageUp = 11, // ASCII code for Page Up key
- chReturn = 13, // ASCII code for Return character
- chRight = 29, // ASCII code for right arrow
- chSpace = 32, // ASCII code for Space character
- chTab = 9, // ASCII code for Tab character
- chUp = 30 // ASCII code for up arrow
- };
-
- //========================================================================================
- // FW_MTSMHandler - a mixin for views that use the Text Services Manager
- //========================================================================================
- class FW_MTSMHandler
- {
- public:
- FW_DECLARE_CLASS
-
- FW_MTSMHandler(FW_CEditView* theView);
- virtual ~FW_MTSMHandler();
-
- FW_Boolean CreateTSMDocument(TEHandle te);
-
- FW_Boolean DoActivateTSM(FW_Boolean becomingActive);
- FW_Boolean DoFixTSMDocument();
-
- TSMDocumentID GetTSMDocument() const;
- void SetTSMDocument(TSMDocumentID docId);
-
- private:
- TSMDocumentID fTSMDocId;
- TSMTERecHandle fTSMHandle;
- FW_CEditView* fEditView;
- OSErr fError; // error from last TSM call
- };
-
- //----------------------------------------------------------------------------------------
- inline TSMDocumentID FW_MTSMHandler::GetTSMDocument() const
- {
- return fTSMDocId;
- }
-
- //----------------------------------------------------------------------------------------
- inline void FW_MTSMHandler::SetTSMDocument(TSMDocumentID docId)
- {
- fTSMDocId = docId;
- }
-
- //========================================================================================
- // CEditNotification
- //========================================================================================
- class CEditNotification : public FW_CNotification
- {
- public:
- CEditNotification(FW_CEditView* editView);
- CEditNotification(const CEditNotification& other);
- virtual ~CEditNotification();
-
- FW_Boolean operator==(const CEditNotification& other);
- CEditNotification& operator=(const CEditNotification& other);
-
- FW_CEditView* GetEditView(Environment* ev) const;
- ODID GetViewId(Environment* ev) const;
-
- private:
- FW_CEditView* fEditView;
- };
-
- //----------------------------------------------------------------------------------------
- inline FW_CEditView* CEditNotification::GetEditView(Environment* ev) const
- {
- return fEditView;
- }
-
- //----------------------------------------------------------------------------------------
- inline ODID CEditNotification::GetViewId(Environment* ev) const
- {
- return fEditView->GetViewId(ev);
- }
-
- //========================================================================================
- // CMyEditView - experiment with typing Undo/Redo
- //========================================================================================
- class CMyEditView : public FW_CEditView
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CMyEditView)
-
- public:
- CMyEditView(Environment* ev,
- FW_CSuperView* container,
- ODID viewId,
- const FW_CRect& bounds,
- const FW_CFont& font,
- short maxChars,
- unsigned short attributes);
- virtual ~ CMyEditView();
-
- public:
- virtual void DeactivateTarget(Environment* ev);
- virtual FW_Boolean DoCharKey(Environment* ev, const FW_CCharKeyEvent& event);
- virtual FW_Boolean DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
- virtual FW_Boolean DoMouseDown(Environment* ev, const FW_CMouseEvent& event);
-
- void LinkToReceiver(FW_MReceiver* receiver);
-
- protected:
- void DoneTyping(Environment* ev);
- FW_Boolean IsArrowKey(char ch);
-
- private:
- CTypingCommand* NewTypingCommand(Environment* ev, char firstChar);
-
- protected:
- CTypingCommand* fTypingCommand;
- };
-
- //========================================================================================
- // CJapEditView
- //========================================================================================
- class CJapEditView : public CMyEditView, public FW_MTSMHandler
- {
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(CJapEditView)
-
- public:
- CJapEditView(Environment* ev,
- FW_CSuperView* container,
- ODID viewId,
- const FW_CRect& bounds,
- const FW_CFont& font,
- short maxChars,
- unsigned short attributes);
- virtual ~ CJapEditView();
-
- void InitJapEditView(Environment* ev);
-
- public:
- virtual void ActivateTarget(Environment* ev, FW_Boolean tabSelection);
- virtual void DeactivateTarget(Environment* ev);
-
- virtual FW_Boolean DoCharKey(Environment* ev, const FW_CCharKeyEvent& event);
- virtual FW_Boolean DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
-
- public:
- void AddInput(Environment* ev, CTSMInput* input);
- void DoMakeTypingCommand(Environment* ev = NULL);
- FW_Boolean IsFirstEventInSequence();
-
- private:
- CTSMTypingCommand* NewTypingCommand(Environment* ev, CTSMInput* firstInput);
- CTSMTypingCommand* fTSMTypingCommand;
-
- private:
- short fMyFont; // my font
- short fMyFontScript; // my font's script
- short fPreviousFontScript; // font script saved on activation
- FW_Boolean fFirstActivation;
- };
-
-
- #endif